/*
 * @Author       : NaN 353362604@qq.com
 * @Date         : 2023-05-04 09:50:21
 * @LastEditTime : 2023-07-11 08:26:06
 * @LastEditors  : NaN 353362604@qq.com
 * @FilePath     : \AdminStration\src\Common\Router\MenuNav\FirstLevel\Api.jsx
 * @Description  :
 */
import { API_LIST } from '../../../Api/Api'
import { commonTableList } from '../Common/common'
import {
    AddDataButton,
    ModDataButton,
    DelDataButton,
    SaveExcelButton,
    ExecuteButton,
    OpenTwoRouter,
    OpenSelection,
} from '../Common/options'
import { LaborCompanyList } from '../Common/Conversion'

export const Wage = async ({ url, OptionsEvent, ClientData, Permission, actionRef }) => {
    let data = {
        pageSize: 10,
        params: { pageIndex: 1 },
        get: API_LIST()[`get${url}`],
        added: `pos${url}`,
        modify: `put${url}`,
        delete: `del${url}`,
        options: [
            <AddDataButton OptionsEvent={OptionsEvent} type="primary" icon="add" title="新增" />,
            <OpenSelection
                danger
                key="delete"
                title="批量删除"
                type="primary"
                OptionsEvent={OptionsEvent}
                data={{ type: 'SelectionDelete', url: 'posBatchRemovewages' }}
            />,
        ],
        columns: [
            commonTableList.uuid,
            { ...commonTableList.organizationUuid, valueEnum: ClientData.organization, width: 300 },
            {
                ...commonTableList.tableName,
                title: '劳务公司',
                valueType: 'select',
                rules: true,
                valueEnum: await LaborCompanyList(),
            },
            {
                dataIndex: 'beginTime',
                title: '开始时间',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 150,
            },
            {
                dataIndex: 'endTime',
                title: '结束时间',
                valueType: 'Date',
                ellipsis: true,
                rules: true,
                width: 150,
            },
            {
                title: '操作',
                valueType: 'systemOperation',
                fixed: 'right',
                width: 500,
                hideInSearch: true,
                hideInAdded: true,
                hideInModify: true,
                render: (_, record) => {
                    const { uuid } = record
                    return [
                        <ModDataButton OptionsEvent={OptionsEvent} key="modify" title="修改" data={record} />,
                        <ExecuteButton
                            actionRef={actionRef}
                            key="one"
                            title="重新生成工资"
                            url="putWage"
                            data={record}
                            path={[uuid]}
                            tips="已重新生成!"
                        />,
                        <SaveExcelButton
                            key="excelOne"
                            title="下载工资Excel"
                            api={API_LIST()['getPersonWageDetailExcel']}
                            data={{ WageUuid: uuid }}
                        />,
                        <SaveExcelButton
                            key="excelTwo"
                            title="下载考勤Excel"
                            api={API_LIST()['getAttendanceExcel']}
                            data={{ WageUuid: uuid }}
                        />,
                        <OpenTwoRouter
                            key="two"
                            title="工资明细"
                            modal="TableList"
                            OptionsEvent={OptionsEvent}
                            other={{
                                page: 'Wage',
                                Permission,
                                oneData: record,
                                header: data.columns,
                            }}
                        />,
                        <DelDataButton
                            OptionsEvent={OptionsEvent}
                            key="del"
                            title="删除"
                            url={url}
                            uuid={record.uuid}
                        />,
                    ]
                },
            },
        ],
    }

    return data
}
